import { EnumUserType } from '../../utils/constant.js'
const app = getApp(),url = app.globalData.url;
Page({
  data: {
    Nid:2,
  },

  onLoad: function (options) {
    // console.log(options)
    
  },
  // 切换
  butType(e){
    let that = this
    console.log(e)
    let showView = that.data.showView
    let tid = e.currentTarget.dataset.id
    that.setData({Nid:tid,listdata:[]})

    that.onShow()
  },
  // 搜索
  // search(){
  //   wx.navigateTo({
  //     url: '/HomePage/search/search?sts='+2,
  //   })
  // },
  // 搜索
  searchBut:function(e){
    var that = this
    var uid = wx.getStorageSync('user_massage')
    let status = e.detail.value
    console.log('执行search',status)
    wx.request({
      header: {
        'content-type': 'application/json' // 默认值
      },
      url:url+ 'jobFair/queryAllJobFairByPage',
      method: "POST",
      data:{
        pageNum: 1,
        pageSize: 1136,
        startTime: "",
        title: status,
        userUid: uid.userUid,
      },
      success:function(res){
        console.log("搜索",res);
        var ret = res.data
        if(ret.code == 200){
          var listdata = ret.data.content
          that.setData({listdata:listdata})
        }else{
          wx.showToast({
            title: ret.msg,
            icon:'none'
          })
        }
      }
    })
  },


  jobfairdetail(e){
    var that = this
    let id = e.currentTarget.dataset.id
    var nid = that.data.Nid
    let status = e.currentTarget.dataset.status
    wx.navigateTo({
      url: '/HomePage/jobfairdetail/jobfairdetail?id='+id +'&status='+status+'&nid='+ nid,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this
    var type = that.data.Nid
    let userType = wx.getStorageSync('userType')
    let userUid = ''
    if(userType === EnumUserType.QiYe){
      userUid = wx.getStorageSync('userInfo').enterpriseUid
    } else {
      userUid = wx.getStorageSync('user_massage').userUid
    }
    wx.request({
      url:url+'jobFair/findAllByStatus',
      method: "GET",
      data:{
        pageNum :1,
        pageSize :915,
        state :type,
        userUid
      },
      success:function(res){
        var ret = res.data
        if(ret.code == 200){
          that.setData({
            listdata:ret.data.content
          })
        }else{
          wx.showToast({
            title: ret.msg,
            icon:'none'
          })
        }
      }
    })
  },

  
})